#!/usr/bin/perl -w

use Tk;
use Data::Dumper;

sub dummy {
  if (my @index = $lst1->curselection()) {
    print "Index: $index[0]\n";
  }
  $mw->configure(-title => "Probandoooooo");
}

sub add_experiment {
  $dialog = new Dialog  $dialog = new Dialog;;
}

$mw = new MainWindow;

# SPACES ================================================================
$mw->Label(-text => '') -> grid ( -row => 0, -column => 0, -pady => 0 );
$mw->Label(-text => '') -> grid ( -row => 6, -column => 0, -pady => 0 );

# LABELS =================================================================
$mw->Label(-text => 'Experiments') -> grid ( -row => 1, -column => 0 );
$mw->Label(-text => 'Tests')       -> grid ( -row => 1, -column => 1 );
$mw->Label(-text => 'Fields')      -> grid ( -row => 1, -column => 2 );
$mw->Label(-text => 'Others...')   -> grid ( -row => 1, -column => 3 );
$mw->Label(-text => 'Config file') -> grid ( -row => 7, -column => 1, -columnspan => 2 );

# LISTBOX ================================================================
$lst1 = $mw->Scrolled("Listbox", -scrollbars => "e", -selectmode => "single") -> grid( -row => 2, -column => 0 );
$lst2 = $mw->Scrolled("Listbox", -scrollbars => "e", -selectmode => "single") -> grid( -row => 2, -column => 1 );
$lst3 = $mw->Scrolled("Listbox", -scrollbars => "e", -selectmode => "single") -> grid( -row => 2, -column => 2 );
$lst4 = $mw->Scrolled("Listbox", -scrollbars => "e", -selectmode => "single") -> grid( -row => 2, -column => 3 );

$lst1 -> insert('end', qw/LOCAL TEGASASTE BEOWULF BASE_ene BASE_jun/);
$lst2 -> insert('end', qw/MM100 MM200 MM500 MM500X1000 MM1000 MM10000/);
$lst3 -> insert('end', qw/TEST NAME DIM TIME RESULT/);
$lst4 -> insert('end', qw/VISUAL UNIQUE IS_OK/);

# BUTTONS ===============================================================
$mw->Button(-text => 'Add Experiment',    -command => \&add_experiment )->grid( -row => 3, -column => 0, -sticky => "we" );
$mw->Button(-text => 'Add Test',          -command => \&dummy )->grid( -row => 3, -column => 1, -sticky => "we" );
$mw->Button(-text => 'Add Field',         -command => \&dummy )->grid( -row => 3, -column => 2, -sticky => "we" );
$mw->Button(-text => 'Edit',              -command => \&dummy )->grid( -row => 3, -column => 3, -sticky => "we" );
$mw->Button(-text => 'Edit Experiment',   -command => \&dummy )->grid( -row => 4, -column => 0, -sticky => "we" );
$mw->Button(-text => 'Edit Test',         -command => \&dummy )->grid( -row => 4, -column => 1, -sticky => "we" );
$mw->Button(-text => 'Edit Field',        -command => \&dummy )->grid( -row => 4, -column => 2, -sticky => "we" );
$mw->Button(-text => 'Remove Experiment', -command => \&dummy )->grid( -row => 5, -column => 0, -sticky => "we" );
$mw->Button(-text => 'Remove Test',       -command => \&dummy )->grid( -row => 5, -column => 1, -sticky => "we" );
$mw->Button(-text => 'Remove Field',      -command => \&dummy )->grid( -row => 5, -column => 2, -sticky => "we" );

# TEXTAREA ==============================================================
$mw->Scrolled("Text", -scrollbars => "e", -state => "normal" )->grid( -row => 8, -column => 0, -columnspan => 4, -sticky => "wesn" );

# MENUBAR ===============================================================
$mw->configure(-menu => my $menubar = $mw->Menu);

my $file = $menubar->cascade(-label => '~File');
my $help = $menubar->cascade(-label => '~Help');

# FILE MENU =============================================================
$file->command( -label => 'New',         -command => undef  ); $file->separator;
$file->command( -label => 'Open',        -command => undef  ); $file->separator;
$file->command( -label => 'Save',        -command => undef  );
$file->command( -label => 'Save As ...', -command => undef  ); $file->separator;
$file->command( -label => "Quit",        -command => \&exit );

MainLoop;
